<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>sampleFile - OpenGrok cross reference for /sampleFile</title></head><body>
<script type="text/javascript">/* <![CDATA[ */
function get_sym_list(){return [["Function","xf",[["flush",51],["loop",27],["start_link",22]]]];} /* ]]> */</script><a class="l" name="1" href="#1">1</a><span class="c">%% Copyright (c) 2011-2017, Lo&#239;c Hoguin &lt;essen@ninenines.eu&gt;</span>
<a class="l" name="2" href="#2">2</a><span class="c">%%</span>
<a class="l" name="3" href="#3">3</a><span class="c">%% Permission to use, copy, modify, <a href="/source/s?path=and/">and</a>/<a href="/source/s?path=and/or">or</a> distribute this software for any</span>
<a class="l" name="4" href="#4">4</a><span class="c">%% purpose with or without fee is hereby granted, provided that the above</span>
<a class="l" name="5" href="#5">5</a><span class="c">%% copyright notice and this permission notice appear in all copies.</span>
<a class="l" name="6" href="#6">6</a><span class="c">%%</span>
<a class="l" name="7" href="#7">7</a><span class="c">%% THE SOFTWARE IS PROVIDED &quot;AS IS&quot; AND THE AUTHOR DISCLAIMS ALL WARRANTIES</span>
<a class="l" name="8" href="#8">8</a><span class="c">%% WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF</span>
<a class="l" name="9" href="#9">9</a><span class="c">%% MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR</span>
<a class="hl" name="10" href="#10">10</a><span class="c">%% ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES</span>
<a class="l" name="11" href="#11">11</a><span class="c">%% WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN</span>
<a class="l" name="12" href="#12">12</a><span class="c">%% ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF</span>
<a class="l" name="13" href="#13">13</a><span class="c">%% OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.</span>
<a class="l" name="14" href="#14">14</a>
<a class="l" name="15" href="#15">15</a>-<b>module</b>(<a class="d" name="ranch_acceptor"/><a href="/source/s?refs=ranch_acceptor" class="d intelliWindow-symbol" data-definition-place="def">ranch_acceptor</a>).
<a class="l" name="16" href="#16">16</a>
<a class="l" name="17" href="#17">17</a>-<b>export</b>([<a class="d intelliWindow-symbol" href="#start_link" data-definition-place="defined-in-file">start_link</a>/<span class="n">3</span>]).
<a class="l" name="18" href="#18">18</a>-<b>export</b>([<a class="d intelliWindow-symbol" href="#loop" data-definition-place="defined-in-file">loop</a>/<span class="n">3</span>]).
<a class="l" name="19" href="#19">19</a>
<a class="hl" name="20" href="#20">20</a>-<b>spec</b> <a class="d intelliWindow-symbol" href="#start_link" data-definition-place="defined-in-file">start_link</a>(<a href="/source/s?defs=inet" class="intelliWindow-symbol" data-definition-place="undefined-in-file">inet</a>:<a href="/source/s?defs=socket" class="intelliWindow-symbol" data-definition-place="undefined-in-file">socket</a>(), <a href="/source/s?defs=module" class="intelliWindow-symbol" data-definition-place="undefined-in-file">module</a>(), <a href="/source/s?defs=pid" class="intelliWindow-symbol" data-definition-place="undefined-in-file">pid</a>())
<a class="l" name="21" href="#21">21</a>	-&gt; {<a href="/source/s?defs=ok" class="intelliWindow-symbol" data-definition-place="undefined-in-file">ok</a>, <a href="/source/s?defs=pid" class="intelliWindow-symbol" data-definition-place="undefined-in-file">pid</a>()}.
<a class="l" name="22" href="#22">22</a><a class="xf" name="start_link"/><a href="/source/s?refs=start_link" class="xf intelliWindow-symbol" data-definition-place="def">start_link</a>(<a href="/source/s?defs=LSocket" class="intelliWindow-symbol" data-definition-place="undefined-in-file">LSocket</a>, <a href="/source/s?defs=Transport" class="intelliWindow-symbol" data-definition-place="undefined-in-file">Transport</a>, <a href="/source/s?defs=ConnsSup" class="intelliWindow-symbol" data-definition-place="undefined-in-file">ConnsSup</a>) -&gt;
<a class="l" name="23" href="#23">23</a>	<a href="/source/s?defs=Pid" class="intelliWindow-symbol" data-definition-place="undefined-in-file">Pid</a> = <a href="/source/s?defs=spawn_link" class="intelliWindow-symbol" data-definition-place="undefined-in-file">spawn_link</a>(<span class="xm">?MODULE</span>, <a class="d intelliWindow-symbol" href="#loop" data-definition-place="defined-in-file">loop</a>, [<a href="/source/s?defs=LSocket" class="intelliWindow-symbol" data-definition-place="undefined-in-file">LSocket</a>, <a href="/source/s?defs=Transport" class="intelliWindow-symbol" data-definition-place="undefined-in-file">Transport</a>, <a href="/source/s?defs=ConnsSup" class="intelliWindow-symbol" data-definition-place="undefined-in-file">ConnsSup</a>]),
<a class="l" name="24" href="#24">24</a>	{<a href="/source/s?defs=ok" class="intelliWindow-symbol" data-definition-place="undefined-in-file">ok</a>, <a href="/source/s?defs=Pid" class="intelliWindow-symbol" data-definition-place="undefined-in-file">Pid</a>}.
<a class="l" name="25" href="#25">25</a>
<a class="l" name="26" href="#26">26</a>-<b>spec</b> <a class="d intelliWindow-symbol" href="#loop" data-definition-place="defined-in-file">loop</a>(<a href="/source/s?defs=inet" class="intelliWindow-symbol" data-definition-place="undefined-in-file">inet</a>:<a href="/source/s?defs=socket" class="intelliWindow-symbol" data-definition-place="undefined-in-file">socket</a>(), <a href="/source/s?defs=module" class="intelliWindow-symbol" data-definition-place="undefined-in-file">module</a>(), <a href="/source/s?defs=pid" class="intelliWindow-symbol" data-definition-place="undefined-in-file">pid</a>()) -&gt; <a href="/source/s?defs=no_return" class="intelliWindow-symbol" data-definition-place="undefined-in-file">no_return</a>().
<a class="l" name="27" href="#27">27</a><a class="xf" name="loop"/><a href="/source/s?refs=loop" class="xf intelliWindow-symbol" data-definition-place="def">loop</a>(<a href="/source/s?defs=LSocket" class="intelliWindow-symbol" data-definition-place="undefined-in-file">LSocket</a>, <a href="/source/s?defs=Transport" class="intelliWindow-symbol" data-definition-place="undefined-in-file">Transport</a>, <a href="/source/s?defs=ConnsSup" class="intelliWindow-symbol" data-definition-place="undefined-in-file">ConnsSup</a>) -&gt;
<a class="l" name="28" href="#28">28</a>	_ = <b>case</b> <a href="/source/s?defs=Transport" class="intelliWindow-symbol" data-definition-place="undefined-in-file">Transport</a>:<a href="/source/s?defs=accept" class="intelliWindow-symbol" data-definition-place="undefined-in-file">accept</a>(<a href="/source/s?defs=LSocket" class="intelliWindow-symbol" data-definition-place="undefined-in-file">LSocket</a>, <a href="/source/s?defs=infinity" class="intelliWindow-symbol" data-definition-place="undefined-in-file">infinity</a>) <b>of</b>
<a class="l" name="29" href="#29">29</a>		{<a href="/source/s?defs=ok" class="intelliWindow-symbol" data-definition-place="undefined-in-file">ok</a>, <a href="/source/s?defs=CSocket" class="intelliWindow-symbol" data-definition-place="undefined-in-file">CSocket</a>} -&gt;
<a class="hl" name="30" href="#30">30</a>			<b>case</b> <a href="/source/s?defs=Transport" class="intelliWindow-symbol" data-definition-place="undefined-in-file">Transport</a>:<a href="/source/s?defs=controlling_process" class="intelliWindow-symbol" data-definition-place="undefined-in-file">controlling_process</a>(<a href="/source/s?defs=CSocket" class="intelliWindow-symbol" data-definition-place="undefined-in-file">CSocket</a>, <a href="/source/s?defs=ConnsSup" class="intelliWindow-symbol" data-definition-place="undefined-in-file">ConnsSup</a>) <b>of</b>
<a class="l" name="31" href="#31">31</a>				<a href="/source/s?defs=ok" class="intelliWindow-symbol" data-definition-place="undefined-in-file">ok</a> -&gt;
<a class="l" name="32" href="#32">32</a>					<span class="c">%% This call will not return until process has been started</span>
<a class="l" name="33" href="#33">33</a>					<span class="c">%% AND we are below the maximum number of connections.</span>
<a class="l" name="34" href="#34">34</a>					<a href="/source/s?defs=ranch_conns_sup" class="intelliWindow-symbol" data-definition-place="undefined-in-file">ranch_conns_sup</a>:<a href="/source/s?defs=start_protocol" class="intelliWindow-symbol" data-definition-place="undefined-in-file">start_protocol</a>(<a href="/source/s?defs=ConnsSup" class="intelliWindow-symbol" data-definition-place="undefined-in-file">ConnsSup</a>, <a href="/source/s?defs=CSocket" class="intelliWindow-symbol" data-definition-place="undefined-in-file">CSocket</a>);
<a class="l" name="35" href="#35">35</a>				{<a href="/source/s?defs=error" class="intelliWindow-symbol" data-definition-place="undefined-in-file">error</a>, _} -&gt;
<a class="l" name="36" href="#36">36</a>					<a href="/source/s?defs=Transport" class="intelliWindow-symbol" data-definition-place="undefined-in-file">Transport</a>:<a href="/source/s?defs=close" class="intelliWindow-symbol" data-definition-place="undefined-in-file">close</a>(<a href="/source/s?defs=CSocket" class="intelliWindow-symbol" data-definition-place="undefined-in-file">CSocket</a>)
<a class="l" name="37" href="#37">37</a>			<b>end</b>;
<a class="l" name="38" href="#38">38</a>		<span class="c">%% Reduce the accept rate if we run out of file descriptors.</span>
<a class="l" name="39" href="#39">39</a>		<span class="c">%% We can&apos;t accept anymore anyway, so we might as well wait</span>
<a class="hl" name="40" href="#40">40</a>		<span class="c">%% a little for the situation to resolve itself.</span>
<a class="l" name="41" href="#41">41</a>		{<a href="/source/s?defs=error" class="intelliWindow-symbol" data-definition-place="undefined-in-file">error</a>, <a href="/source/s?defs=emfile" class="intelliWindow-symbol" data-definition-place="undefined-in-file">emfile</a>} -&gt;
<a class="l" name="42" href="#42">42</a>			<a href="/source/s?defs=error_logger" class="intelliWindow-symbol" data-definition-place="undefined-in-file">error_logger</a>:<a href="/source/s?defs=warning_msg" class="intelliWindow-symbol" data-definition-place="undefined-in-file">warning_msg</a>(<span class="s">&quot;Ranch acceptor reducing accept rate: out of file descriptors~n&quot;</span>),
<a class="l" name="43" href="#43">43</a>			<b>receive</b> <b>after</b> <span class="n">0xFF</span> -&gt; <a href="/source/s?defs=ok" class="intelliWindow-symbol" data-definition-place="undefined-in-file">ok</a> <b>end</b>;
<a class="l" name="44" href="#44">44</a>		<span class="c">%% We want to crash if the listening socket got closed.</span>
<a class="l" name="45" href="#45">45</a>		{<a href="/source/s?defs=error" class="intelliWindow-symbol" data-definition-place="undefined-in-file">error</a>, <a href="/source/s?defs=Reason" class="intelliWindow-symbol" data-definition-place="undefined-in-file">Reason</a>} <b>when</b> <a href="/source/s?defs=Reason" class="intelliWindow-symbol" data-definition-place="undefined-in-file">Reason</a> =/= <a href="/source/s?defs=closed" class="intelliWindow-symbol" data-definition-place="undefined-in-file">closed</a> -&gt;
<a class="l" name="46" href="#46">46</a>			<a href="/source/s?defs=ok" class="intelliWindow-symbol" data-definition-place="undefined-in-file">ok</a>
<a class="l" name="47" href="#47">47</a>	<b>end</b>,
<a class="l" name="48" href="#48">48</a>	<a class="d intelliWindow-symbol" href="#flush" data-definition-place="defined-in-file">flush</a>(),
<a class="l" name="49" href="#49">49</a>	<span class="xm">?MODULE</span>:<a class="d intelliWindow-symbol" href="#loop" data-definition-place="defined-in-file">loop</a>(<a href="/source/s?defs=LSocket" class="intelliWindow-symbol" data-definition-place="undefined-in-file">LSocket</a>, <a href="/source/s?defs=Transport" class="intelliWindow-symbol" data-definition-place="undefined-in-file">Transport</a>, <a href="/source/s?defs=ConnsSup" class="intelliWindow-symbol" data-definition-place="undefined-in-file">ConnsSup</a>).
<a class="hl" name="50" href="#50">50</a>
<a class="l" name="51" href="#51">51</a><a class="xf" name="flush"/><a href="/source/s?refs=flush" class="xf intelliWindow-symbol" data-definition-place="def">flush</a>() -&gt;
<a class="l" name="52" href="#52">52</a>	<b>receive</b> <a href="/source/s?defs=Msg" class="intelliWindow-symbol" data-definition-place="undefined-in-file">Msg</a> -&gt;
<a class="l" name="53" href="#53">53</a>		<a href="/source/s?defs=error_logger" class="intelliWindow-symbol" data-definition-place="undefined-in-file">error_logger</a>:<a href="/source/s?defs=error_msg" class="intelliWindow-symbol" data-definition-place="undefined-in-file">error_msg</a>(
<a class="l" name="54" href="#54">54</a>			<span class="s">&quot;Ranch acceptor received unexpected message: ~p~n&quot;</span>,
<a class="l" name="55" href="#55">55</a>			[<a href="/source/s?defs=Msg" class="intelliWindow-symbol" data-definition-place="undefined-in-file">Msg</a>]),
<a class="l" name="56" href="#56">56</a>		<a class="d intelliWindow-symbol" href="#flush" data-definition-place="defined-in-file">flush</a>()
<a class="l" name="57" href="#57">57</a>	<b>after</b> <span class="n">0</span> -&gt;
<a class="l" name="58" href="#58">58</a>		<a href="/source/s?defs=ok" class="intelliWindow-symbol" data-definition-place="undefined-in-file">ok</a>
<a class="l" name="59" href="#59">59</a>	<b>end</b>.
<a class="hl" name="60" href="#60">60</a><span class="s">&apos;<a href="http://example.com?a=">http://example.com?a=</a>&apos;</span>
<a class="l" name="61" href="#61">61</a>-<b>include</b>(<span class="s">&quot;<a href="/source/s?path=incdir/">incdir</a>/<a href="/source/s?path=incdir/more_records.hrl">more_records.hrl</a>&quot;</span>).
<a class="l" name="62" href="#62">62</a></body>
</html>
